<template>

		<u-badge type="warning" :value="msgnum" :offset="[-35,-5]" :absolute="true" :showZero="true"></u-badge>

</template>

<script>
    import {mapState,mapMutations} from 'vuex';
	import socket from "@/plugins/socket";
	export default {
		props: {
			item:{},
			iconcolor:''
		},
		data() {
			return {
				albumWidth:0,
				msgnum:'..'
			};
		},
	computed: {
		//...mapState(["user"]),
	},
	created() {
		let _this = this;
		//if (this.iconcolor==''||this.iconcolor==undefined)this.iconcolor="#63E5CB";
		this.msgnum=this.$store.state.chatmsgnoread

		socket.acceptMessage = function (res) {
		  console.log("页面接收到数据chat",res);
		  if (res.type == "ping") {
			_this.$store.commit("setChatmsgnoread", res.isnoread);
			_this.msgnum=res.isnoread;
		  }
		};
	},
	methods:{
		gotochathome(){
			if (this.user.extConfig.chatinswitchTab==0){
				this.$Router.push({path: '/pagesPackageA/chat/chathome'})
			}else{
				uni.switchTab({url: `/pagesPackageA/chat/chathome`,success: function (e) {}})
			}
			
		}
	}
}
</script>

<style lang="scss"></style>
